home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / LaserWriterIIsc (New GX v1.1) / LaserSCIntf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-20  |  7.7 KB  |  198 lines  |  [TEXT/MPS ]

  1. /*---------------------------------------------------------------------------------------------
  2. FILENAME
  3.  
  4.     LaserSCIntf.h
  5.     
  6. DESCRIPTION
  7.  
  8.     This file contains constant and type declarations for the data structures which are needed
  9.     to use the LaserSCIntf.c code module. That code module provides a set of high level routines
  10.     for invoking LaserWriterSC device commands.
  11.  
  12. COPYRIGHT
  13.  
  14.     Copyright Apple Computer, Inc.  1989-1992
  15.     All rights reserved.
  16.         
  17. ---------------------------------------------------------------------------------------------*/
  18.  
  19. #ifndef __LASERSCINTF__
  20. #define __LASERSCINTF__
  21.  
  22. /*********************************************************************************
  23.  *                                         CONSTANTS                                                     *
  24.  *********************************************************************************/
  25.  
  26. // LaserWriterSC Sense Key Codes (causes of a Check Condition status) 
  27. enum
  28. {
  29.     kNotReady                = 0x2,                            // Printer not ready (e.g. door open) 
  30.     kMediumError            = 0x3,                            // Paper jam has occurred 
  31.     kHardwareError            = 0x4,                            // Non-recoverable hardware error 
  32.     kIllegalRequest        = 0x5,                            // Illegal command parameter passed to printer 
  33.     kUnitAttention            = 0x6,                            // Printer has been turned on or reset 
  34.     kAbortedCommand        = 0xB                                // Checksum mismatch in downloaded code 
  35. };
  36.  
  37. // LaserWriterSC Controller Status Bits and some Sense Data Bits 
  38. enum
  39. {
  40.     // Controller Status 
  41.     kRamFailMask            = 0x20,                            // Dynamic RAM test failure 
  42.     kEngineFailMask        = 0x10,                            // Laser printer engine initialization failure 
  43.     
  44.     // Sense Data 
  45.     kEndOfMedium            = 0x40                            // Bit set when out of paper, or in manual mode and no paper fed in 
  46. };
  47.  
  48. // LaserWriterSC Engine Status 0 Bits - defines problem when kNotReady Sense Key received 
  49. enum
  50. {
  51.     kToner                     = 0x40,                            // No toner cartridge installed or installed improperly 
  52.     kTray                     = 0x20,                            // No paper cartridge installed or installed improperly 
  53.     kPaperOut                 = 0x10,                            // Paper out, or if in manual feed mode no paper has been fed in 
  54.     kJam                         = 0x08,                            // Paper jam 
  55.     kDoorOpened             = 0x04,                            // Upper door of printer is open 
  56.     kTestPrint                 = 0x02,                            // Test printing is underway 
  57.     kHeatFixUnit             = 0x01                            // LaserWriter's fixing unit is being heated 
  58. };
  59.  
  60. // LaserWriterSC Engine Status 1 Bits - defines problem when kHardwareError Sense Key received 
  61. enum 
  62. {
  63.     kFixingMalfunction     = 0x40,                            // Fixing assembly has malfunctioned 
  64.     kLaserMalfunction     = 0x20,                            // Laser has malfunctioned 
  65.     kPolyMalfunction         = 0x10,                            // Polygon motor has malfunctioned 
  66.     kSerialMalfunction     = 0x01                            // Serial communication malfunction has occurred 
  67. };
  68.  
  69. // SCSI status byte values useful for checking state of printer 
  70. enum
  71. {
  72.     kGoodCondition            = 0,                                // Printer not experiencing exception condition 
  73.     kCheckCondition        = 2,                                // Printer is experiencing exception condition 
  74.     kBusy                        = 8                                // Device is busy 
  75. };
  76.  
  77. // Definitions for the printer firmware SCSI commands
  78. enum
  79. {
  80.      kSCReserved            = 0x0000,
  81.      kSCPrinterReady    = 0x0000,
  82.     kSCResetPrinter    = 0x0100,
  83.     kSCDownLoadCode    = 0x0200,
  84.     kSCRequestSense    = 0x0300,
  85.     kSCFormatMargin    = 0x0400,
  86.     kSCFormatImage        = 0x0402,
  87.     kSCDrawBits            = 0x0500,
  88.     kSCClearBits        = 0x0600,
  89.     kSCPrint                = 0x0A00,
  90.     kSCInquiry            = 0x1200,
  91.     kSCModeSelect        = 0x1500,
  92.     kSCReserveUnit        = 0x1600,
  93.     kSCReleaseUnit        = 0x1700,
  94.     kSCModeSense        = 0x1A00
  95. };
  96.  
  97.  
  98. /*********************************************************************************
  99.  *                                             TYPES                                                     *
  100.  *********************************************************************************/
  101.  
  102. // SCInquiryData - Format of a LaserWriter SC Inquiry Response 
  103.  
  104. typedef struct
  105. {
  106.     // First five bytes of structure are common to all SCSI devices. Layout of remaining bytes 
  107.     // is specific to the LaserWriter SC 
  108.     
  109.     unsigned char        peripheralType;        // Type of SCSI peripheral (2 = printer type) 
  110.     unsigned char        deviceType;                // Type of Apple printer 
  111.     unsigned char        version;                    // Version not currently being used 
  112.     unsigned char        reserved1;                // Reserved 
  113.     unsigned char        additionalLength;        //    Number of bytes which follow (39 for II SC) 
  114.     
  115.     unsigned char        appleUnique;            // Apple unique byte specifying toner, RAM and Paper size 
  116.     unsigned char        reserved2;                // Reserved 
  117.     unsigned char        reserved3;                // Reserved 
  118.     char                    vendorID[8];            // Vendor identifier in ASCII = "APPLE   " 
  119.     char                    productID[16];            // Product identifier in ASCII = "PERSONAL LASER  " 
  120.     char                    revisionLevel[4];        // Revision level in ASCII (e.g. "1.00") 
  121.     short                    reserved4;                // Reserved 
  122.     char                    cmndsImplemented[6];    // Commands supported by the device 
  123. }    SCInquiryData,
  124.     *SCInquiryDataPtr;
  125.  
  126.  
  127. // SCSenseData - Format of LaserWriter SC Request Sense Data 
  128.  
  129. typedef struct
  130. {
  131.     unsigned char        errorType;                // Error class portion (always 7)
  132.     unsigned char        reserved1;                // Reserved
  133.     unsigned char        senseKey;                // Special flags indicating things like out of paper
  134.     unsigned char        infoByte3;                // Four fields indicating difference between the requested 
  135.     unsigned char        infoByte2;                //    allocation size and the actual memory available on
  136.     unsigned char        infoByte1;                // the printer.
  137.     unsigned char        infoByte0;                // 
  138.     unsigned char        additionalSense;        // Apple unique sense data
  139.     unsigned char        engineStatus0;            // Field for not ready sense key
  140.     unsigned char        engineStatus1;            // Field for hardware error sense key
  141.     unsigned char        controlStatus;            // Indicates if hardware errors during diagnostics
  142.     unsigned char        reserved2;                // Reserved
  143. }    SCSenseData,
  144.     *SCSenseDataPtr;
  145.  
  146.  
  147. /*********************************************************************************
  148.  *                                            DEFINES                                                    *
  149.  *********************************************************************************/
  150.  
  151. #define    SenseKey(senseData)            ((senseData.senseKey) & 0x0F)
  152.  
  153. #define    EngineStatus0(pSenseData, bitField)    (((pSenseData->engineStatus0 & bitField) == bitField) ? true : false)
  154. #define    NoToner(pSenseData)                        (EngineStatus0(pSenseData, kToner))
  155. #define    NoPaperTray(pSenseData)                    (EngineStatus0(pSenseData, kTray))
  156. #define    NoPaper(pSenseData)                        (EngineStatus0(pSenseData, kPaperOut))
  157. #define    PaperJam(pSenseData)                        (EngineStatus0(pSenseData, kJam))
  158. #define    DoorOpen(pSenseData)                        (EngineStatus0(pSenseData, kDoorOpened))
  159. #define    TestPrint(pSenseData)                    (EngineStatus0(pSenseData, kTestPrint))
  160. #define    HeatingFixUnit(pSenseData)                (EngineStatus0(pSenseData, kHeatFixUnit))
  161.  
  162. #define    EngineStatus1(pSenseData, bitField)    (((pSenseData->engineStatus1 & bitField) == bitField) ? true : false)
  163. #define    FixingMalfunction(pSenseData)            (EngineStatus1(pSenseData, kFixingMalfunction))
  164. #define    LaserMalfunction(pSenseData)            (EngineStatus1(pSenseData, kLaserMalfunction))
  165. #define    PolyMalfunction(pSenseData)            (EngineStatus1(pSenseData, kPolyMalfunction))
  166. #define    SerialMalfunction(pSenseData)            (EngineStatus1(pSenseData, kSerialMalfunction))
  167.  
  168.  
  169. /*********************************************************************************
  170.  *                                    FORWARD DECLARATIONS                                            *
  171. **********************************************************************************/
  172.  
  173. OSErr LaserSC_OpenConnection();
  174.  
  175. OSErr LaserSC_GetDeviceStatus(short *deviceStatus);
  176.  
  177. OSErr LaserSC_ResetDevice();
  178.  
  179. OSErr LaserSC_GetSenseData(SCSenseDataPtr senseData);
  180.  
  181. OSErr LaserSC_SetPageMargins(short leftMargin, short topMargin);
  182.  
  183. OSErr LaserSC_SetPageDimensions(short bytesPerScanLine, short numScanLines);
  184.  
  185. OSErr LaserSC_ClearBits(Rect *rectToClear);
  186.  
  187. OSErr LaserSC_DrawBits(Ptr imageData, Rect *rectToDrawIn, short numBytesPerLine, short qdTransferMode);
  188.  
  189. OSErr LaserSC_PrintPage(Boolean continuousPrint, Boolean clearPage); 
  190.  
  191. OSErr LaserSC_QueryPrinter(SCInquiryDataPtr inquiryData, char querySize);
  192.  
  193. OSErr LaserSC_SetBuffandFeedMode(Boolean manualFeed, Boolean bufferedMode);
  194.  
  195. long LaserSC_GetTimeoutForSCSICmnd(short scsiCmnd);
  196.  
  197.  
  198. #endif __LASERSCINTF__